package svc

import (
    "github.com/SpectatorNan/gorm-zero/gormc/config/mysql"
   	"github.com/zeromicro/go-zero/core/stores/redis"
   	"gorm.io/gorm"
    "gozerodemo/pkg/databases/gormx"
   	{{.imports}}
)

type ServiceContext struct {
	Config config.Config

	Data
}

type Data struct {
	TxModel   gormx.TxModel
	// todo: add your data model here and delete this line
}

func NewData(db *gorm.DB, redis *redis.Redis) Data {
	return Data{
		TxModel:   gormx.NewTxModel(db),
	}
}


func NewServiceContext(c config.Config) *ServiceContext {
   	mysqlCli := gormx.MustNewMysql(c.Mysql)
	redisCli := redis.MustNewRedis(c.RedisConf)

	return &ServiceContext{
		Config:c,
		Data:     NewData(mysqlCli,redisCli),
	}
}
